package com.mach.platform.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import org.springframework.http.HttpStatus;

import java.io.Serializable;
import java.util.HashMap;

/**
 * @author Administrator
 * @Name
 * @Description: 返回前段实体
 * @date 2018/4/23 0023   10:56
 */
@ApiModel(value = "返回类")
@Data
@Builder
public class Response implements Serializable{

	private static final long serialVersionUID = -2103342547380143891L;

	@ApiModelProperty(value = "状态码",notes = "状态码 --- ")
	private Integer status;

	@ApiModelProperty(value = "提示信息")
	private String msg;

	@ApiModelProperty(value = "返回数据存放体")
	private Object data;

	private Object jsData = new HashMap<>();

	public static Response ok() {
		return Response.builder().msg("操作成功").status(HttpStatus.OK.value()).build();
	}

	public static Response ok(String msg) {
		return Response.builder().msg(msg).status(HttpStatus.OK.value()).build();
	}

	public static Response ok(Object obj) {
		return Response.builder().msg("操作成功").data(obj).status(HttpStatus.OK.value()).build();
	}

	public static Response error() {
		return Response.builder().status(HttpStatus.FORBIDDEN.value()).build();
	}

	public static Response error(String msg) {
		return Response.builder().msg(msg).status(HttpStatus.FORBIDDEN.value()).build();
	}

}
